package co.fitstart.entity.order;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.annotation.JSONField;

public class PaymentRequest {
    
    @JSONField(name = "appid")
    private String appid;
    
    @JSONField(name = "channel")
    private String channel;
    
    @JSONField(name = "order_no")
    private String orderNo;
    
    @JSONField(name = "customer_id")
    private Long customerId;
    
    @JSONField(name = "amount")
    private int amount;
    
    @JSONField(name = "pay_time")
    private String payTime;
    
    @JSONField(name = "request_no")
    private String requestNo;
    
    @JSONField(name = "signature")
    private String signature;
    
    @JSONField(name = "order_number")
    private String orderNumber;
    
    /**
     * 
     */
    public PaymentRequest() {
    }
    
    /**
     * 
     * @return
     */
    public boolean isValid() {
        
        return StringUtils.isNoneBlank(appid) && StringUtils.isNoneBlank(requestNo) &&
               StringUtils.isNoneBlank(orderNo) && StringUtils.isNoneBlank(payTime) && 
               StringUtils.isNoneBlank(channel) && StringUtils.isNoneBlank(signature) && 
               (customerId != null) && (amount >= 0);
        
    }
    
    /**
     * 
     * @return
     */
    public Map<String, String> describe() {
        
        Map<String, String> result = new LinkedHashMap<String, String>();
        
        result.put("appid", this.appid);
        result.put("channel", this.channel);
        result.put("order_no", this.orderNo);
        result.put("customer_id", this.customerId.toString());
        result.put("amount", String.valueOf(this.amount));
        result.put("pay_time", this.payTime);
        result.put("request_no", this.requestNo);
        
        return result;
    }

    /**
     * @return the appid
     */
    public String getAppid() {
        return appid;
    }

    /**
     * @return the channel
     */
    public String getChannel() {
        return channel;
    }

    /**
     * @return the orderNo
     */
    public String getOrderNo() {
        return orderNo;
    }

    /**
     * @return the customerId
     */
    public Long getCustomerId() {
        return customerId;
    }

    /**
     * @return the amount
     */
    public int getAmount() {
        return amount;
    }

    /**
     * @return the payTime
     */
    public String getPayTime() {
        return payTime;
    }

    /**
     * @return the requestNo
     */
    public String getRequestNo() {
        return requestNo;
    }

    /**
     * @return the signature
     */
    public String getSignature() {
        return signature;
    }

    /**
     * @return the orderNumber
     */
    public String getOrderNumber() {
        return orderNumber;
    }

    /**
     * @param appid the appid to set
     */
    public void setAppid(String appid) {
        this.appid = appid;
    }

    /**
     * @param channel the channel to set
     */
    public void setChannel(String channel) {
        this.channel = channel;
    }

    /**
     * @param orderNo the orderNo to set
     */
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    /**
     * @param customerId the customerId to set
     */
    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    /**
     * @param payTime the payTime to set
     */
    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    /**
     * @param requestNo the requestNo to set
     */
    public void setRequestNo(String requestNo) {
        this.requestNo = requestNo;
    }

    /**
     * @param signature the signature to set
     */
    public void setSignature(String signature) {
        this.signature = signature;
    }

    /**
     * @param orderNumber the orderNumber to set
     */
    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

}
